<!DOCTYPE html>
<html>
<head>
<title>招标中的借款</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "../../../include/resources.html">
<script type="text/javascript">
    var dataGrid;
    var winWidth =  800;
    var winHeight = 400;
    var borrowDetailTitle = "查看借款标";
    var borrowDetailUrl =  "/modules/loan/borrow/showBorrowDetailPage.html";
    var borrowDetailWinParmeters = "'{0}','"+borrowDetailTitle+"',700,360,'"+borrowDetailUrl+"'";
    
    var cancelTitle = "撤标";
    var cancelUrl =  "/modules/loan/borrow/cancelBorrowPage.html";
    var cancelWinParmeters = "'{0}','"+cancelTitle+"',1000,530,'"+cancelUrl+"'";
    
    var tenderListTitle="投标记录";
    var tenderListUrl =  "/modules/loan/borrow/tenderDetailPage.html"; 
	var tenderListWinParmeters = "'{0}','"+tenderListTitle+"',800,500,'"+tenderListUrl+"'";
	
	var isRecommendUrl = "/modules/loan/borrow/recommendBorrow.html"; 
	var isRecommendWinParmeters = "'{0}','"+isRecommendUrl+"','确定要推荐吗？'";
	var isRecommendTitle = "确定要推荐吗？";

    var isUnRecommendUrl = "/modules/loan/borrow/unRecommendBorrow.html";
    var isUnRecommendWinParmeters = "'{0}','"+isRecommendUrl+"','确定取消推荐吗？'";
    var isUnRecommendTitle = "确定取消推荐吗？";
	
	var stopBorrowTitle="确定要截标吗？";
	var stopBorrowUrl = "/modules/loan/borrow/stopBorrowPage.html"; 
	var stopBorrowWinParmeters = "'{0}','"+stopBorrowTitle+"',800,500,'"+stopBorrowUrl+"','确定'";
	
	var stopFlowTitle="确定要停止流转吗?停止流转后将不可恢复";
	var stopflowUrl = "/modules/loan/borrow/stopFlowPage.html"; 
	var stopflowWinParmeters = "'{0}','"+stopFlowTitle+"',800,500,'"+stopflowUrl+"','确定'";
	
	var confirmUrl = "/modules/loan/borrow/registerBorrowResult.html";
	var openUrl= "/modules/loan/borrow/cancelBorrowSkip.html";
	var registerBorrowParmeters = "'{0}','" + openUrl+"'";
	var openTitle = "确定要撤标吗？撤标后将不可恢复";
  
    $(function() {
        dataGrid = $('#dataGrid').datagrid({
            url : 'borrowBiddingList.html',
            fit : true,
            fitColumns:true,
            border : false,
            pagination : true,
            idField : 'id',
            pageSize : pageSize,
            pageNums :1,
            pageList : pageList,
            sortName : 'id',
            sortOrder : 'asc',
            checkOnSelect : false,
            selectOnCheck : false,
            nowrap : false,
            singleSelect:true,
            columns : [ [
              { field: 'id', title: '编号', width: 50,fixed:true, sortable:false },              
              { field: 'userName', title: '用户名', width: 100, sortable:false },
              { field: 'realName', title: '借款人姓名', width: 80, sortable:false },
              { field: 'name', title: '标名', width: 150, sortable:false },  
              { field: 'type', title: '类型', width: 60, sortable:false , 
		          formatter: function(value,row,index){
		            return borrowType(value);
		            }  
              },
              { field: 'account', title: '借款金额(元)',sortable:false,formatter:function(value,row,index){
                return value;
              } },
              {field:'accountYes',title:'已投金额(元)',formatter:function(value,row,index){
                return value;
              }},
              { field: 'apr', title: '利率', width: 50, sortable:false,formatter: function(value,row,index){
                return value+"%";
              } }, 
              { field: 'timeLimit', title: '借款期限', width: 60, sortable:false,
	                formatter: function(value,row,index){
			              if (row.borrowTimeType == 1){
			                return row.timeLimit + "天";
			              } else {
			                return value + "个月";
			              }
	            	}
              },
              { field: 'addTime', title: '发布时间', width: 150,fixed:true, sortable:false, 
                  formatter: function(value,row,index){
                    return getLocalTime(value,4);
              }  
              },
              { field: 'scales', title: '进度', width: 60,fixed:true, sortable:false,formatter: function(value,row,index){
                return value+"%";
              }},
              { field : 'showInfo',
                  title : '其他信息',
                  width :75,
                  align:'center',
                  fixed:true,
                  formatter : function(value, row, index) {
                	  var mostAccount = row.mostAccount;
                	  if(mostAccount == 0){
                		  mostAccount = '无限制';
                	  }
                	  var content = '<a href="javascript:void(0);" class="j-showInfo">查看<i class="iconfont">&#xe639;</i></a>'
							+ '<div class="showInfoSingleDiv">'
							+ '<div class="showInfo">'
							+ '<em></em><h2>借款标信息</h2>'
							+ '<ul>'
	  						+ '<li>'
	                  		+ '<span>最低投标额：</span>'
	  						+ row.lowestAccount
	  						+ '</li>'
	  						+ '<li>'
	                  		+ '<span>最多投标额：</span>'
	  						+ mostAccount
	  						+ '</li>'
	  						+ '<li>'
	                  		+ '<span>添加时间：</span>'
	  						+ getLocalTime(row.addTime, 4);
	  						+ '</li>'
	  						+ '<li>'
	                  		+ '<span>开标时间：</span>'
	  						+ getLocalTime(row.putStartTime, 4);
	  						+ '</li>'
	  						+ '<li>'
	                  		+ '<span>IP：</span>'
	  						+ row.addIp
	  						+ '</li>'
	  						+ '</ul></div></div>';
	  					return content;
	  				}
	  		  },
              { field : 'action',
                title : '操作',
                width :75,
                fixed:true,
                align:'center',
                formatter : function(value, row, index) {
                  var str = '';
                  str += '<dl>';
                  str += '<dt><a href="javascript:void(0);" onclick="$.fn.formOptions.viewFun('+row.id+',borrowDetailTitle,winWidth,winHeight,borrowDetailUrl);" title="'+borrowDetailTitle+'">查看</a><i class="iconfont">&#xe639;</i></dt>' ;
                  str += '<dd>';
                  str += '<a href="javascript:void(0);" onclick="$.fn.formOptions.viewFun('+row.id+',tenderListTitle,winWidth,winHeight,tenderListUrl);" title="'+tenderListTitle+'">记录</a>';
                  if(row.type==110){
                    if(row.status==0){//审核
                    }else{//停止流转
                       str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',stopFlowTitle,winWidth,winHeight,stopflowUrl);" title="'+stopFlowTitle+'">停止</a>';
                    }
                  }else{
                      if(row.status==1 && (row.account>row.accountYes)&&(row.accountYes>0) && row.type != 101){
                        str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',stopBorrowTitle,winWidth,winHeight,stopBorrowUrl);" title="'+stopBorrowTitle+'">截标</a>';
                      }
                  }
               	   if(row.recommend==false){
                         str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.deleteFun('+row.id+',isRecommendUrl,isRecommendTitle);" title="推荐">推荐</a>';
                   	}
                    else{
                         str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.deleteFun('+row.id+',isUnRecommendUrl,isUnRecommendTitle);" title="取消推荐">取消推荐</a>';
                   }
                    if(row.type!=110){
                        str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',cancelTitle,winWidth,winHeight,cancelUrl);" title="'+cancelTitle+'">撤回</a>';
                    }
                str += '</dd>'
                str +=  '</dl>'
                return str;
                }
            } ] ],
            onLoadSuccess : function() {
                $('#searchForm table').show();
                parent.$.messager.progress('close');
            }
        }); 
        
    });
       
</script>
</head>
<body style="padding:0 20px;" >
    <div class="easyui-layout" data-options="fit : true,border : false">
        <div data-options="region:'north',border:false,collapsible:false" id="searchBox">
            <div class="sLeft">
	            <form id="searchForm">
	            	<input type="text"  name="searchName" class="sInput" placeholder="输入借款人姓名/用户名/标名进行搜索" autocomplete="off" onkeydown="if(event.keyCode == 13){ $.fn.dataGridOptions.searchFun('#searchForm');return false;}"/><a href="javascript:;" title="查询" class="sBtn" onclick="$.fn.dataGridOptions.searchFun('#searchForm');">查询</a><a href="javascript:;" class="advBtn" title="条件查询">条件查询 <i class="iconfont">&#xe638;</i></a>
                        <a href="javascript:void(0);" class="reloadIcon" onclick="dataGrid.datagrid('reload');" title="刷新" ><i class="iconfont">&#xe603;</i></a>
	            </form>
            </div>
            <form id="showAdw">
		        <ul class="showAdw" style="display:none;">
		        	<a href="javascript:void(0);"><i class="iconfont closeWin">&#xe63a;</i></a>
		        	<li><span>标的类型</span><select name="type" class="type"><option value="全部">全部</option><#list borrowConfigList as item><option value="${item.id}">${item.name}</option></#list></select></li>
		       		<li><span>借款人姓名</span><input type="text" name="realName" autocomplete="off"/></li>
		       		<li><span>用户名</span><input type="text" name="userName" autocomplete="off"/></li>
		       		<li><span>时间</span><input type="text" name="startTime" id="startTime" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTime\')}',readOnly:true})" class="searchTime"/>&nbsp;-&nbsp;<input type="text" name="endTime" id="endTime" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}',readOnly:true})" class="searchTime"/></li>
		       		<li><span>&nbsp;</span><a href="javascript:void(0);" class="searchBtn sureBtn" onclick="$.fn.dataGridOptions.searchFun('#showAdw');">确定</a><a href="javascript:void(0);" class="searchBtn" onclick="$.fn.dataGridOptions.cleanFun('#searchForm');">重置</a></li>
		        </ul>
	        </form>
        </div>
        <div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
            <table id="dataGrid"></table>
        </div>
    </div>
</body>
</html>
<script src="${theme_dir}/js/search.js"></script>
